import React from 'react';
import {StyleSheet, View, ToastAndroid, ScrollView} from 'react-native';
import * as Color from "../constant/Color";
import {NormalLine} from "../widget/lineitem/NormalLine";
import {TitleValueLine} from "../widget/lineitem/TitleValueLine";
import {SwitcherLine} from "../widget/lineitem/SwitcherLine";
import {CheckLine} from "../widget/lineitem/CheckLine";
import {WheelItem, WheelLine} from "../widget/lineitem/WheelLine";
import {SeekBarLine} from "../widget/lineitem/SeekBarLine";
import {CustomSeekBarLine, SeekBarItem, SeekbarItem} from "../widget/lineitem/CustomSeekBarLine";

/** LineItem */
export default class PageLineItem extends React.Component {

    render() {
        return (
            <ScrollView>
                <View style={styles.container}>
                    <NormalLine     title={"测试标题"}/>

                    <TitleValueLine title={"不可编辑"} value={"不可编辑"} info={""} editable={false} onPress={null}/>
                    <TitleValueLine title={"标题"} value={"值"} info={"提示信息"} editable={true} onPress={(text) => {this._show(text)}}/>

                    <SwitcherLine   title={"开关"} isChecked={true} editable={false} onSwitch={null}/>
                    <SwitcherLine   title={"开关"} isChecked={true} editable={true} onSwitch={(newValue) => {this._onSwitch(newValue)}}/>

                    <CheckLine      title={"打勾"} isChecked={true} editable={false} onSwitch={null}/>
                    <CheckLine      title={"打勾"} isChecked={true} editable={true} onSwitch={(newValue) => {this._onSwitch(newValue)}}/>

                    <WheelLine      title={"弹出选择"} value={"value2"} info={"提示信息"} editable={true} datas={WheelItem.getTestDatas()} onPress={(text) => {this._show(text)}}/>
                    <SeekBarLine    title={"SeekBar"} value={5} editable={true} onPress={(text) => {this._show(text)}}/>
                    <CustomSeekBarLine title={"CustomSeekBarLine"} editable={true} datas={Array.from(SeekBarItem.getTestDatas())} value={SeekBarItem.getOne()} onPress={(text) => {this._show(text)}}/>
                </View>
            </ScrollView>
        );
    }

    _show(text:string):void{
        ToastAndroid.show (text, ToastAndroid.SHORT);
    }

    _onSwitch(newValue:boolean):void{
        ToastAndroid.show (newValue ? '是' : '否', ToastAndroid.SHORT);
    }
}

//样式定义
const styles = StyleSheet.create({
    container: {
        // flex:1,
        flexDirection: 'column',
        // alignItems: 'center',
        // justifyContent: 'center',
        backgroundColor: Color.windowWhite,
    },
});


